﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LeanEngine.Entity
{
    public static class MetaTableCache
    {
        #region PropertyInfo Members

        private static Dictionary<int, MetaTable> CachedItemsList { get; set; }

        #endregion

        #region Constructor Members

        static MetaTableCache()
        {
            CachedItemsList = new Dictionary<int, MetaTable>();
        }

        #endregion

        #region Method Members

        public static MetaTable GetItem(Type entityType)
        {
            lock(CachedItemsList)
            {
                if(!CachedItemsList.ContainsKey(entityType.GetHashCode()))
                {
                    CachedItemsList.Add(entityType.GetHashCode(), new MetaTable(entityType));
                }
            }

            return CachedItemsList[entityType.GetHashCode()];
        }

        #endregion
    }
}
